#include "port.h"
#include "fpga-common.h"
#include "interface/protocal-ocid.h"
#include "fpga-private.h"

// 正式产品要把这个东西删掉，现在没空让小胡改fpga_open_interface()代替// 正式产品要把这个东西删掉，现在没空让小胡改fpga_open()
#define TRK300_DBG (1)


int fpga_alarm(struct fpga_dev *dev, int ch, int is_appear)
{
    PRINT_FUTURE("\r\n请用 fpga_if_set_gpio代替fpga_alarm\r\n"
                 "fpga_if_set_gpio(dev, IO_OCID_ALARM_BASE + ch, is_appear)\r\n");
    // fpga_if_set_gpio(dev, IO_OCID_SENSITIVE, sensitive);
    return cb_fpga_alarm(dev, ch, is_appear);
}

int fpga_ocid_param(struct fpga_dev *dev, struct fpga_ocid_test_param *val)
{
    printf("%s() \r\n", __FUNCTION__);
#if TRK300_DBG
    return cp_fpga_ocid_param(dev, val);
#else
    return fpga_if_wrirte_regs(dev, 0, val, 0);
#endif
}

int fpga_ocid_start(struct fpga_dev *dev)
{
    printf("%s() \r\n", __FUNCTION__);
#if TRK300_DBG
    return cp_fpga_ocid_start(dev);
#else
    return fpga_if_start(dev);
#endif
}

int fpga_read_ocid_data(struct fpga_dev *dev, unsigned char *ocid_data, unsigned long len, unsigned long *rlen)
{
    return cp_fpga_read_ocid_data(dev, ocid_data, len, rlen);
}

// int fpga_otdr_isfinish(struct fpga_dev *dev, bool *val)
// {
// 	return fpga_if_isfinish(dev, val);
// }

int fpga_ocid_stop(struct fpga_dev *dev)
{
    return cp_fpga_ocid_stop(dev);
}

int fpga_ocid_sensitive(struct fpga_dev *dev, int sensitive)
{
    PRINT_FUTURE("\r\n请用 fpga_if_set_gpio代替fpga_ocid_sensitive\r\n"
                 "fpga_if_set_gpio(dev, IO_OCID_SENSITIVE, sensitive)\r\n");
    // fpga_if_set_gpio(dev, IO_OCID_SENSITIVE, sensitive);
    cp_fpga_ocid_sensitive(dev, sensitive);
}
